﻿@{
    ViewBag.Title = "PublicForm";
    Layout = "~/Views/Shared/_Form.cshtml";

}@using LeSoft.Application.Code;
<script>
    var keyValue = request('keyValue'), organizeid = "";
    var _organizeid = "@OperatorProvider.Provider.Current().CompanyId";
    $(function () {
        initControl();      
    })
   
    //初始化控件
    function initControl() {

        $("#Nature").ComboBox({
            param:"2",
            data: [{ "key": "1", "value": "单元表" }, { "key": "2", "value": "公用表" }, { "key": "3", "value": "虚拟表" }],
            id: "key",
            text: "value",
            description: "==请选择=="           
        });
       

        $("#Type").ComboBoxTree({
            url: "../../SystemManage/DataItemDetail/GetDataItemTreeJson?Encode=EnergyMeterType",
            description: "==请选表种类==",
            height: "150px"
        });
       
        $("#PStructId").ComboBoxTree({
            url: "../../ResourceManage/RS_PStructs/GetTreeJson",
            description: "==请选所属区域==",
            height: "150px"
        });
        $("#ParentId").ComboBoxTree({
            url: "../../ResourceManage/RS_EnergyMeter/GetParentTreeJson",
            description: "==请选父表==",
            height: "150px"
        });

        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_EnergyMeter/GetPublicFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                }
            });
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        $.SaveForm({
            url: "../../ResourceManage/RS_EnergyMeter/SaveInstanceForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable2").resetSelection();
                $.currentIframe().$("#gridTable2").trigger("reloadGrid");
            }
        })
    }

    function aa() {   
        var s = $('#MeterTyperadio input[name="MeterType"]:checked ').val();
        $("#MeterType").val(s);        
    }
    
</script>
@*<h2>PublicForm</h2>*@
<div class="ui-layout" id="layout" style="height: 100%; width: 95%;">
    <table class="form" style="margin:0px auto; margin-top:20px;">
        <tr>
            <td class="formTitle">表名称<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Name" class="form-control" isvalid="yes" checkexpession="NotNull" type="text" /></td>
            <td class="formTitle">表编号<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Code" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
        </tr>
        <tr>
            <td class="formTitle">表种类<font face="宋体">*</font></td>
            <td class="formValue" colspan="3">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
            <td class="formTitle">表类型<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Nature" type="hidden" value="2" />
                <input type="text"  class="form-control" isvalid="yes" checkexpession="NotNull" readonly="readonly" value="公用表"  />
            </td>
        </tr>
        <tr>
            <td class="formTitle">表容量</td>
            <td class="formValue" colspan="3"><input id="Volume" class="form-control" type="number" /></td>
            <td class="formTitle">走表类型</td>
            <td class="formValue" colspan="3">
                <input id="MeterType" type="hidden" value="1" />
                <div id="MeterTyperadio" class="radio">
                    <label><input name="MeterType" type="radio" onclick="aa();" checked="checked" value="1" />正转</label>
                    <label><input name="MeterType" type="radio" onclick="aa();" value="2" />反转</label>
                </div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">倍率<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Rate" type="number" value="1"  class="form-control" isvalid="yes" checkexpession="NotNull" /></td>
            <td class="formTitle">量程<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="Range" type="number" value="999999" class="form-control" isvalid="yes" checkexpession="NotNull" /></td>

        </tr>
        <tr>
            <td class="formTitle">最低用量<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="MinVolume" class="form-control" value="1" isvalid="yes" checkexpession="NotNull" type="number" /></td>
            <td class="formTitle">最高用量<font face="宋体">*</font></td>
            <td class="formValue" colspan="3"><input id="MaxVolume" class="form-control" value="999999"  isvalid="yes" checkexpession="NotNull" type="number" /></td>
            </tr>
        <tr>
            <td class="formTitle">单价</td>
            <td class="formValue" colspan="3"><input id="UnitPrice" class="form-control" isvalid="yes" checkexpession="IsMoney" type="number" /></td>
            <td class="formTitle">表位置</td>
            <td class="formValue" colspan="3"><input id="PSMemo" class="form-control" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle">所属区域<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">
                <div id="PStructId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">父表<font face="宋体">*</font></td>
            <td class="formValue" colspan="7">           
                <div id="ParentId" type="selectTree" class="ui-select" ></div>
            </td>
        </tr>
        <tr>
            <td class="formTitle">备注</td>
            <td class="formValue" colspan="7"><textarea id="Description" class="form-control" style="height: 70px;"></textarea></td>
        </tr>
    </table>
</div>
